package jfox.platform.logging.entity;

import java.util.Map;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import jfox.platform.infrastructure.EntityObject;

/**
 * @author <a href="mailto:jfox.young@gmail.com">Young Yang</a>
 */
@Entity
@Table(name = "T_SYS_LOG")
public class Log extends EntityObject {

    @Column(name = "MODULE_ID")
    private long moduleId;

    @Column(name = "MODULE_NAME")
    private String moduleName;

    @Column(name = "NODE_ID")
    private long nodeId;

    @Column(name = "NODE_NAME")
    private String nodeName;

    @Column(name = "IP_ADDRESS")
    private String ipAddress;

    @Column(name = "SUCCESS")
    private String success;

    @Column(name = "TYPE")
    private String type;

    @Column(name = "COMSUMED_MILLISECONDS")
    private long consumedMilliSeconds;

    public final static String TYPE_SYSTEM = "S";
    public final static String TYPE_BUSINESS = "B";

    public final static String SUCCESS_YES = "Y";
    public final static String SUCCESS_NO = "N";

/*
    @Column(name = "PAYLOAD")
    private byte[] payload;
*/

    public long getModuleId() {
        return moduleId;
    }

    public void setModuleId(long moduleId) {
        this.moduleId = moduleId;
    }

    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public long getNodeId() {
        return nodeId;
    }

    public void setNodeId(long nodeId) {
        this.nodeId = nodeId;
    }

    public String getNodeName() {
        return nodeName;
    }

    public void setNodeName(String nodeName) {
        this.nodeName = nodeName;
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    public String getSuccess() {
        return success;
    }

    public void setSuccess(String success) {
        this.success = success;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

/*
    public byte[] getPayload() {
        return payload;
    }

    public void setPayload(byte[] payload) {
        this.payload = payload;
    }
*/

    public long getConsumedMilliSeconds() {
        return consumedMilliSeconds;
    }

    public void setConsumedMilliSeconds(long consumedMilliSeconds) {
        this.consumedMilliSeconds = consumedMilliSeconds;
    }

    public Map<String, Object> convertToMap() {
        Map<String, Object> map = super.convertToMap();
        map.put("NODE_NAME_WITH_ACTION_NAME", getNodeName() + "(" + getName() + ")");
        return map;
    }

    public static void main(String[] args) {

    }
}
